<?php

namespace app\admin\validate;
use think\Validate;
class AdminUser extends Validate
{
    protected $rule = [
        'username' => 'require|max:25',
        'password' => 'require|max:25',
        'captcha' => 'require|checkCapcha',
    ];

    protected $message = [
        'username.require' => '用户名不能为空',
        'username.max' => '用户名不能超过25个字符',
        'password.require' => '密码不能为空',
        'password.max' => '密码不能超过25个字符',
        'captcha.require' => '验证码不能为空'
    ];

    protected function checkCapcha($value, $rule, $data = [])
    {
        if(!captcha_check($value)){
            return "你输入的验证码不正确!";
        }
        return true;
    }
}